﻿
namespace NetROS.Tiers.Windows.Forms
{
	/// <summary>
	/// abstract Klijent typed datagridview
	/// </summary>
	[System.ComponentModel.DesignerCategoryAttribute("code")]
	public abstract class KlijentDataGridViewBase : System.Windows.Forms.UserControl
	{	
		/// <summary> 
		/// Thrown when the current Entity changed.
		/// </summary>
		public event System.EventHandler<KlijentDataGridViewEventArgs> CurrentEntityChanged;
		
		#region Fields
				
		/// <summary> 
		/// the current entity.
		/// </summary>
		private Entities.Klijent _currentKlijent = null;
		//private Dictionary<string, string> _columnsHeaders = new Dictionary<string, string>();
		
		/// <summary> 
		/// the datagridview instance
		/// </summary>
		protected System.Windows.Forms.DataGridView uxKlijentDataGridView;
		
		/// <summary> 
		/// the errorprovider
		/// </summary>
		protected System.Windows.Forms.ErrorProvider uxKlijentErrorProvider;
		
		/// <summary> 
		/// the bindingsource
		/// </summary>
		protected System.Windows.Forms.BindingSource uxKlijentBindingSource;
		
		
		/// <summary> 
		/// the DGV column associated with the ID property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxIDDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ImeKlijenta property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxImeKlijentaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the MB property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxMBDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Adresa property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxAdresaDataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDMjesto property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDMjestoDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Telefon property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxTelefonDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Telefon2 property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxTelefon2DataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Fax property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxFaxDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Fax2 property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxFax2DataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the WebAdresa property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxWebAdresaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ZiroRacun property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxZiroRacunDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ZiroRacun2 property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxZiroRacun2DataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the ZiroRacun3 property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxZiroRacun3DataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Napomena1 property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNapomena1DataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Napomena2 property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxNapomena2DataGridViewColumn;
		/// <summary> 
		/// the DGV column associated with the IDTip property
		/// </summary>
		protected System.Windows.Forms.DataGridViewComboBoxColumn uxIDTipDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the OIB property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxOIBDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the GarancijaPlacanjaOpis property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxGarancijaPlacanjaOpisDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the GarancijaPlacanjaVrijednost property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxGarancijaPlacanjaVrijednostDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the DaniOdgodePlacanja property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxDaniOdgodePlacanjaDataGridViewColumn;
		
		/// <summary> 
		/// the DGV column associated with the Komentar property
		/// </summary>
		protected System.Windows.Forms.DataGridViewTextBoxColumn uxKomentarDataGridViewColumn;
		
		#endregion
					
		#region Combo list
		
				
		private Entities.TList<Entities.KlijentTip> _IDTipList;
		
		/// <summary> 
		/// The list of selectable KlijentTip
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.KlijentTip> IDTipList
		{
			get {return this._IDTipList;}
			set 
			{
				this._IDTipList = value;
				this.uxIDTipDataGridViewColumn.DataSource = null;
				this.uxIDTipDataGridViewColumn.DataSource = this._IDTipList;
			}
		}
		
		private bool _allowNewItemInIDTipList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of KlijentTip
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDTipList
		{
			get { return _allowNewItemInIDTipList;}
			set
			{
				this._allowNewItemInIDTipList = value;
				this.uxIDTipDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
				
		private Entities.TList<Entities.Mjesto> _IDMjestoList;
		
		/// <summary> 
		/// The list of selectable Mjesto
		/// </summary>
		[System.ComponentModel.Category("DropDownList BindingSources")]
		public Entities.TList<Entities.Mjesto> IDMjestoList
		{
			get {return this._IDMjestoList;}
			set 
			{
				this._IDMjestoList = value;
				this.uxIDMjestoDataGridViewColumn.DataSource = null;
				this.uxIDMjestoDataGridViewColumn.DataSource = this._IDMjestoList;
			}
		}
		
		private bool _allowNewItemInIDMjestoList;
		
		/// <summary> 
		/// Indicates if user can add an item in the list of Mjesto
		/// </summary>
		[System.ComponentModel.Category(".netTiers"), System.ComponentModel.Description("Indicates if end user can add a new item in the combobox. an event will be thrown then.")]
		public bool AllowNewItemInIDMjestoList
		{
			get { return _allowNewItemInIDMjestoList;}
			set
			{
				this._allowNewItemInIDMjestoList = value;
				this.uxIDMjestoDataGridViewColumn.DisplayStyle = value ? System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox : System.Windows.Forms.DataGridViewComboBoxDisplayStyle.DropDownButton;
			}
		}
		
		#endregion
		
		#region Main Datasource
		
		private Entities.TList<Entities.Klijent> _KlijentList;
				
		/// <summary> 
		/// The list of Klijent to be displayed in the DGV.
		/// </summary>
		[System.ComponentModel.Category("Data")]
		public Entities.TList<Entities.Klijent> KlijentList
		{
			get {return this._KlijentList;}
			set
			{
				this._KlijentList = value;
				this.uxKlijentBindingSource.DataSource = null;
				this.uxKlijentBindingSource.DataSource = value;
				this.uxKlijentDataGridView.DataSource = null;
				this.uxKlijentDataGridView.DataSource = this.uxKlijentBindingSource;				
				//this.uxKlijentBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(uxKlijentBindingSource_ListChanged);
				this.uxKlijentBindingSource.CurrentItemChanged += new System.EventHandler(OnKlijentBindingSourceCurrentItemChanged);
			}
		}
		
		private void OnKlijentBindingSourceCurrentItemChanged(object sender, System.EventArgs e)
		{
			_currentKlijent = uxKlijentBindingSource.Current as Entities.Klijent;
			
			if (_currentKlijent != null)
			{
				_currentKlijent.Validate();
			}
			//_Klijent.Validate();
			OnCurrentEntityChanged();
		}

		//void uxKlijentBindingSource_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
		//{
			//throw new Exception("The method or operation is not implemented.");
		//}		
		
		#endregion
		
		/// <summary>
		/// Gets the currently selected <c cref="Entities.Klijent"/> instance.
		/// </summary>
		public Entities.Klijent SelectedKlijent
		{
			get {return this._currentKlijent;}
		}
		
		#region other properties
		
		/// <summary>
		/// Gets or sets a value indicating whether you have provided your own data-management operations for the DataGridView control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool VirtualMode
		{
			get {return this.uxKlijentDataGridView.VirtualMode;}
			set
			{
				this.uxKlijentDataGridView.VirtualMode = value;
			}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the option to add rows is displayed to the user.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToAddRows
		{
			get {return this.uxKlijentDataGridView.AllowUserToAddRows;}
			set {this.uxKlijentDataGridView.AllowUserToAddRows = value;}
		}
		
		/// <summary>
		/// Gets or sets a value indicating whether the user is allowed to delete rows from the DataGridView.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public bool AllowUserToDeleteRows
		{
			get {return this.uxKlijentDataGridView.AllowUserToDeleteRows;}
			set {this.uxKlijentDataGridView.AllowUserToDeleteRows = value;}
		}
		
		/// <summary>
		/// Gets the <c cref="DataGridView"/> instance.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]
		public System.Windows.Forms.DataGridView DataGridView
		{
			get {return this.uxKlijentDataGridView;}
		}
		
		/// <summary>
		/// Gets a collection that contains all the columns in the control.
		/// </summary>
		[System.ComponentModel.Category(".netTiers")]		
		[System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Visible)]
		//[System.ComponentModel.EditorAttribute("System.Windows.Forms.Design.DataGridViewColumnCollectionEditor, System.Design", typeof(System.Drawing.Design.UITypeEditor))] 
		public System.Windows.Forms.DataGridViewColumnCollection Columns
		{
			get { return this.uxKlijentDataGridView.Columns; }
		}
		
		#endregion
		
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}
	
		#region Constructor
	
		/// <summary>
		/// Initializes a new instance of the <see cref="KlijentDataGridViewBase"/> class.
		/// </summary>
		public KlijentDataGridViewBase()
		{			
			this.components = new System.ComponentModel.Container();			
			
			this.uxKlijentDataGridView = new System.Windows.Forms.DataGridView();
			this.uxKlijentBindingSource = new System.Windows.Forms.BindingSource(this.components);
			this.uxKlijentErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
			this.uxIDDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxImeKlijentaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxMBDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxAdresaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDMjestoDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxTelefonDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxTelefon2DataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxFaxDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxFax2DataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxWebAdresaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxZiroRacunDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxZiroRacun2DataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxZiroRacun3DataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNapomena1DataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxNapomena2DataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxIDTipDataGridViewColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
			this.uxOIBDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxGarancijaPlacanjaOpisDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxDaniOdgodePlacanjaDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			this.uxKomentarDataGridViewColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
			//this.uxIDTipBindingSource = new KlijentTipBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDTipBindingSource)).BeginInit();
			//this.uxIDMjestoBindingSource = new MjestoBindingSource(this.components);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDMjestoBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKlijentDataGridView)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKlijentBindingSource)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKlijentErrorProvider)).BeginInit();
			this.SuspendLayout();
						
			// 
			// uxKlijentErrorProvider
			// 
			this.uxKlijentErrorProvider.ContainerControl = this;
			this.uxKlijentErrorProvider.DataSource = this.uxKlijentBindingSource;						
			// 
			// uxKlijentDataGridView
			// 
			this.uxKlijentDataGridView.AutoGenerateColumns = false;
			this.uxKlijentDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.uxKlijentDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
		this.uxIDDataGridViewColumn,
		this.uxImeKlijentaDataGridViewColumn,
		this.uxMBDataGridViewColumn,
		this.uxAdresaDataGridViewColumn,
		this.uxIDMjestoDataGridViewColumn,
		this.uxTelefonDataGridViewColumn,
		this.uxTelefon2DataGridViewColumn,
		this.uxFaxDataGridViewColumn,
		this.uxFax2DataGridViewColumn,
		this.uxWebAdresaDataGridViewColumn,
		this.uxZiroRacunDataGridViewColumn,
		this.uxZiroRacun2DataGridViewColumn,
		this.uxZiroRacun3DataGridViewColumn,
		this.uxNapomena1DataGridViewColumn,
		this.uxNapomena2DataGridViewColumn,
		this.uxIDTipDataGridViewColumn,
		this.uxOIBDataGridViewColumn,
		this.uxGarancijaPlacanjaOpisDataGridViewColumn,
		this.uxGarancijaPlacanjaVrijednostDataGridViewColumn,
		this.uxDaniOdgodePlacanjaDataGridViewColumn,
		this.uxKomentarDataGridViewColumn			});
			this.uxKlijentDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
			this.uxKlijentDataGridView.Location = new System.Drawing.Point(0, 0);
			this.uxKlijentDataGridView.Name = "uxKlijentDataGridView";
			this.uxKlijentDataGridView.Size = new System.Drawing.Size(470, 300);
			this.uxKlijentDataGridView.TabIndex = 0;	
			this.uxKlijentDataGridView.BackgroundColor = System.Drawing.Color.WhiteSmoke;
			this.uxKlijentDataGridView.EnableHeadersVisualStyles = false;
			this.uxKlijentDataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.OnKlijentDataGridViewDataError);
			this.uxKlijentDataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnKlijentDataGridViewCellValueNeeded);
			this.uxKlijentDataGridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.OnKlijentDataGridViewCellValuePushed);
			
			//
			// uxIDDataGridViewColumn
			//
			this.uxIDDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDDataGridViewColumn.DataPropertyName = "ID";
			this.uxIDDataGridViewColumn.HeaderText = "ID";
			this.uxIDDataGridViewColumn.Name = "uxIDDataGridViewColumn";
			this.uxIDDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDDataGridViewColumn.ReadOnly = true;		
			//
			// uxImeKlijentaDataGridViewColumn
			//
			this.uxImeKlijentaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxImeKlijentaDataGridViewColumn.DataPropertyName = "ImeKlijenta";
			this.uxImeKlijentaDataGridViewColumn.HeaderText = "ImeKlijenta";
			this.uxImeKlijentaDataGridViewColumn.Name = "uxImeKlijentaDataGridViewColumn";
			this.uxImeKlijentaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxImeKlijentaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxImeKlijentaDataGridViewColumn.ReadOnly = false;		
			//
			// uxMBDataGridViewColumn
			//
			this.uxMBDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxMBDataGridViewColumn.DataPropertyName = "MB";
			this.uxMBDataGridViewColumn.HeaderText = "MB";
			this.uxMBDataGridViewColumn.Name = "uxMBDataGridViewColumn";
			this.uxMBDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxMBDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxMBDataGridViewColumn.ReadOnly = false;		
			//
			// uxAdresaDataGridViewColumn
			//
			this.uxAdresaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxAdresaDataGridViewColumn.DataPropertyName = "Adresa";
			this.uxAdresaDataGridViewColumn.HeaderText = "Adresa";
			this.uxAdresaDataGridViewColumn.Name = "uxAdresaDataGridViewColumn";
			this.uxAdresaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxAdresaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxAdresaDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDMjestoDataGridViewColumn
			//
			this.uxIDMjestoDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDMjestoDataGridViewColumn.DataPropertyName = "IDMjesto";
			this.uxIDMjestoDataGridViewColumn.HeaderText = "IDMjesto";
			this.uxIDMjestoDataGridViewColumn.Name = "uxIDMjestoDataGridViewColumn";
			this.uxIDMjestoDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDMjestoDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDMjestoDataGridViewColumn.ReadOnly = false;		
			//
			// uxTelefonDataGridViewColumn
			//
			this.uxTelefonDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxTelefonDataGridViewColumn.DataPropertyName = "Telefon";
			this.uxTelefonDataGridViewColumn.HeaderText = "Telefon";
			this.uxTelefonDataGridViewColumn.Name = "uxTelefonDataGridViewColumn";
			this.uxTelefonDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxTelefonDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxTelefonDataGridViewColumn.ReadOnly = false;		
			//
			// uxTelefon2DataGridViewColumn
			//
			this.uxTelefon2DataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxTelefon2DataGridViewColumn.DataPropertyName = "Telefon2";
			this.uxTelefon2DataGridViewColumn.HeaderText = "Telefon2";
			this.uxTelefon2DataGridViewColumn.Name = "uxTelefon2DataGridViewColumn";
			this.uxTelefon2DataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxTelefon2DataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxTelefon2DataGridViewColumn.ReadOnly = false;		
			//
			// uxFaxDataGridViewColumn
			//
			this.uxFaxDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxFaxDataGridViewColumn.DataPropertyName = "Fax";
			this.uxFaxDataGridViewColumn.HeaderText = "Fax";
			this.uxFaxDataGridViewColumn.Name = "uxFaxDataGridViewColumn";
			this.uxFaxDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxFaxDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxFaxDataGridViewColumn.ReadOnly = false;		
			//
			// uxFax2DataGridViewColumn
			//
			this.uxFax2DataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxFax2DataGridViewColumn.DataPropertyName = "Fax2";
			this.uxFax2DataGridViewColumn.HeaderText = "Fax2";
			this.uxFax2DataGridViewColumn.Name = "uxFax2DataGridViewColumn";
			this.uxFax2DataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxFax2DataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxFax2DataGridViewColumn.ReadOnly = false;		
			//
			// uxWebAdresaDataGridViewColumn
			//
			this.uxWebAdresaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxWebAdresaDataGridViewColumn.DataPropertyName = "WebAdresa";
			this.uxWebAdresaDataGridViewColumn.HeaderText = "WebAdresa";
			this.uxWebAdresaDataGridViewColumn.Name = "uxWebAdresaDataGridViewColumn";
			this.uxWebAdresaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxWebAdresaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxWebAdresaDataGridViewColumn.ReadOnly = false;		
			//
			// uxZiroRacunDataGridViewColumn
			//
			this.uxZiroRacunDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxZiroRacunDataGridViewColumn.DataPropertyName = "ZiroRacun";
			this.uxZiroRacunDataGridViewColumn.HeaderText = "ZiroRacun";
			this.uxZiroRacunDataGridViewColumn.Name = "uxZiroRacunDataGridViewColumn";
			this.uxZiroRacunDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxZiroRacunDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxZiroRacunDataGridViewColumn.ReadOnly = false;		
			//
			// uxZiroRacun2DataGridViewColumn
			//
			this.uxZiroRacun2DataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxZiroRacun2DataGridViewColumn.DataPropertyName = "ZiroRacun2";
			this.uxZiroRacun2DataGridViewColumn.HeaderText = "ZiroRacun2";
			this.uxZiroRacun2DataGridViewColumn.Name = "uxZiroRacun2DataGridViewColumn";
			this.uxZiroRacun2DataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxZiroRacun2DataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxZiroRacun2DataGridViewColumn.ReadOnly = false;		
			//
			// uxZiroRacun3DataGridViewColumn
			//
			this.uxZiroRacun3DataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxZiroRacun3DataGridViewColumn.DataPropertyName = "ZiroRacun3";
			this.uxZiroRacun3DataGridViewColumn.HeaderText = "ZiroRacun3";
			this.uxZiroRacun3DataGridViewColumn.Name = "uxZiroRacun3DataGridViewColumn";
			this.uxZiroRacun3DataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxZiroRacun3DataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxZiroRacun3DataGridViewColumn.ReadOnly = false;		
			//
			// uxNapomena1DataGridViewColumn
			//
			this.uxNapomena1DataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNapomena1DataGridViewColumn.DataPropertyName = "Napomena1";
			this.uxNapomena1DataGridViewColumn.HeaderText = "Napomena1";
			this.uxNapomena1DataGridViewColumn.Name = "uxNapomena1DataGridViewColumn";
			this.uxNapomena1DataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNapomena1DataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNapomena1DataGridViewColumn.ReadOnly = false;		
			//
			// uxNapomena2DataGridViewColumn
			//
			this.uxNapomena2DataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxNapomena2DataGridViewColumn.DataPropertyName = "Napomena2";
			this.uxNapomena2DataGridViewColumn.HeaderText = "Napomena2";
			this.uxNapomena2DataGridViewColumn.Name = "uxNapomena2DataGridViewColumn";
			this.uxNapomena2DataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxNapomena2DataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxNapomena2DataGridViewColumn.ReadOnly = false;		
			//
			// uxIDTipDataGridViewColumn
			//
			this.uxIDTipDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxIDTipDataGridViewColumn.DataPropertyName = "IDTip";
			this.uxIDTipDataGridViewColumn.HeaderText = "IDTip";
			this.uxIDTipDataGridViewColumn.Name = "uxIDTipDataGridViewColumn";
			this.uxIDTipDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxIDTipDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxIDTipDataGridViewColumn.ReadOnly = false;		
			//
			// uxOIBDataGridViewColumn
			//
			this.uxOIBDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxOIBDataGridViewColumn.DataPropertyName = "OIB";
			this.uxOIBDataGridViewColumn.HeaderText = "OIB";
			this.uxOIBDataGridViewColumn.Name = "uxOIBDataGridViewColumn";
			this.uxOIBDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxOIBDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxOIBDataGridViewColumn.ReadOnly = false;		
			//
			// uxGarancijaPlacanjaOpisDataGridViewColumn
			//
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.DataPropertyName = "GarancijaPlacanjaOpis";
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.HeaderText = "GarancijaPlacanjaOpis";
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.Name = "uxGarancijaPlacanjaOpisDataGridViewColumn";
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxGarancijaPlacanjaOpisDataGridViewColumn.ReadOnly = false;		
			//
			// uxGarancijaPlacanjaVrijednostDataGridViewColumn
			//
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.DataPropertyName = "GarancijaPlacanjaVrijednost";
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.HeaderText = "GarancijaPlacanjaVrijednost";
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.Name = "uxGarancijaPlacanjaVrijednostDataGridViewColumn";
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxGarancijaPlacanjaVrijednostDataGridViewColumn.ReadOnly = false;		
			//
			// uxDaniOdgodePlacanjaDataGridViewColumn
			//
			this.uxDaniOdgodePlacanjaDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxDaniOdgodePlacanjaDataGridViewColumn.DataPropertyName = "DaniOdgodePlacanja";
			this.uxDaniOdgodePlacanjaDataGridViewColumn.HeaderText = "DaniOdgodePlacanja";
			this.uxDaniOdgodePlacanjaDataGridViewColumn.Name = "uxDaniOdgodePlacanjaDataGridViewColumn";
			this.uxDaniOdgodePlacanjaDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxDaniOdgodePlacanjaDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxDaniOdgodePlacanjaDataGridViewColumn.ReadOnly = false;		
			//
			// uxKomentarDataGridViewColumn
			//
			this.uxKomentarDataGridViewColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
			this.uxKomentarDataGridViewColumn.DataPropertyName = "Komentar";
			this.uxKomentarDataGridViewColumn.HeaderText = "Komentar";
			this.uxKomentarDataGridViewColumn.Name = "uxKomentarDataGridViewColumn";
			this.uxKomentarDataGridViewColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
			this.uxKomentarDataGridViewColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
			this.uxKomentarDataGridViewColumn.ReadOnly = false;		
			//
			// uxIDTipDataGridViewColumn
			//				
			this.uxIDTipDataGridViewColumn.DisplayMember = "Naziv";	
			this.uxIDTipDataGridViewColumn.ValueMember = "ID";	
			this.uxIDTipDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDTipDataGridViewColumn.DataSource = uxIDTipBindingSource;				
				
			//
			// uxIDMjestoDataGridViewColumn
			//				
			this.uxIDMjestoDataGridViewColumn.DisplayMember = "Naziv";	
			this.uxIDMjestoDataGridViewColumn.ValueMember = "ID";	
			this.uxIDMjestoDataGridViewColumn.DisplayStyleForCurrentCellOnly = true;
			//uxIDMjestoDataGridViewColumn.DataSource = uxIDMjestoBindingSource;				
				
			
			// this
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.uxKlijentDataGridView);
			this.Name = "KlijentDataGridView";
			this.Size = new System.Drawing.Size(470, 300);
			//((System.ComponentModel.ISupportInitialize)(this.uxIDTipBindingSource)).EndInit();
			//((System.ComponentModel.ISupportInitialize)(this.uxIDMjestoBindingSource)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKlijentErrorProvider)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKlijentDataGridView)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.uxKlijentBindingSource)).EndInit();
			this.ResumeLayout(false);
		}
		#endregion
				
		#region events
		
		/// <summary>
		/// Raised the CurrentEntityChanged event.
		/// </summary>
		protected void OnCurrentEntityChanged()
		{
			if (CurrentEntityChanged != null)
			{
				KlijentDataGridViewEventArgs args = new KlijentDataGridViewEventArgs();
				args.Klijent = _currentKlijent;
				CurrentEntityChanged(this, args); 
			}
		}
		
		#endregion
		
		/// <summary>
		/// Strongly typed event 
		/// </summary>
		public class KlijentDataGridViewEventArgs : System.EventArgs
		{
			private Entities.Klijent	_Klijent;
	
			/// <summary>
			/// the  Entities.Klijent instance.
			/// </summary>
			public Entities.Klijent Klijent
			{
				get { return _Klijent; }
				set { _Klijent = value; }
			}	
		}
		
		/// <summary>
		/// Handles the DataError event of the uxKlijentDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewDataErrorEventArgs"/> instance containing the event data.</param>
		protected void OnKlijentDataGridViewDataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
		{
			System.Diagnostics.Debug.WriteLine(string.Format( "{0}, {1}", e.ColumnIndex, e.RowIndex));
		}
		
		/// <summary>
		/// Handles the CellValueNeeded event of the uxKlijentDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnKlijentDataGridViewCellValueNeeded(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxKlijentDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].ID;
						break;
					case "uxImeKlijentaDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].ImeKlijenta;
						break;
					case "uxMBDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].MB;
						break;
					case "uxAdresaDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Adresa;
						break;
					case "uxIDMjestoDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].IDMjesto;
						break;
					case "uxTelefonDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Telefon;
						break;
					case "uxTelefon2DataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Telefon2;
						break;
					case "uxFaxDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Fax;
						break;
					case "uxFax2DataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Fax2;
						break;
					case "uxWebAdresaDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].WebAdresa;
						break;
					case "uxZiroRacunDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].ZiroRacun;
						break;
					case "uxZiroRacun2DataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].ZiroRacun2;
						break;
					case "uxZiroRacun3DataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].ZiroRacun3;
						break;
					case "uxNapomena1DataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Napomena1;
						break;
					case "uxNapomena2DataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Napomena2;
						break;
					case "uxIDTipDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].IDTip;
						break;
					case "uxOIBDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].OIB;
						break;
					case "uxGarancijaPlacanjaOpisDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].GarancijaPlacanjaOpis;
						break;
					case "uxGarancijaPlacanjaVrijednostDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].GarancijaPlacanjaVrijednost;
						break;
					case "uxDaniOdgodePlacanjaDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].DaniOdgodePlacanja;
						break;
					case "uxKomentarDataGridViewColumn":
						e.Value = KlijentList[e.RowIndex].Komentar;
						break;
				default:
				break;
			}
		}
		
		/// <summary>
		/// Handles the CellValuePushed event of the uxKlijentDataGridView control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="T:System.Windows.Forms.DataGridViewCellValueEventArgs"/> instance containing the event data.</param>
		protected void OnKlijentDataGridViewCellValuePushed(object sender, System.Windows.Forms.DataGridViewCellValueEventArgs e)
		{
			switch(uxKlijentDataGridView.Columns[e.ColumnIndex].Name)
			{
					case "uxIDDataGridViewColumn":
						KlijentList[e.RowIndex].ID = (System.Int32)e.Value;
						break;
					case "uxImeKlijentaDataGridViewColumn":
						KlijentList[e.RowIndex].ImeKlijenta = (System.String)e.Value;
						break;
					case "uxMBDataGridViewColumn":
						KlijentList[e.RowIndex].MB = (System.String)e.Value;
						break;
					case "uxAdresaDataGridViewColumn":
						KlijentList[e.RowIndex].Adresa = (System.String)e.Value;
						break;
					case "uxIDMjestoDataGridViewColumn":
						KlijentList[e.RowIndex].IDMjesto = (System.Int32)e.Value;
						break;
					case "uxTelefonDataGridViewColumn":
						KlijentList[e.RowIndex].Telefon = (System.String)e.Value;
						break;
					case "uxTelefon2DataGridViewColumn":
						KlijentList[e.RowIndex].Telefon2 = (System.String)e.Value;
						break;
					case "uxFaxDataGridViewColumn":
						KlijentList[e.RowIndex].Fax = (System.String)e.Value;
						break;
					case "uxFax2DataGridViewColumn":
						KlijentList[e.RowIndex].Fax2 = (System.String)e.Value;
						break;
					case "uxWebAdresaDataGridViewColumn":
						KlijentList[e.RowIndex].WebAdresa = (System.String)e.Value;
						break;
					case "uxZiroRacunDataGridViewColumn":
						KlijentList[e.RowIndex].ZiroRacun = (System.String)e.Value;
						break;
					case "uxZiroRacun2DataGridViewColumn":
						KlijentList[e.RowIndex].ZiroRacun2 = (System.String)e.Value;
						break;
					case "uxZiroRacun3DataGridViewColumn":
						KlijentList[e.RowIndex].ZiroRacun3 = (System.String)e.Value;
						break;
					case "uxNapomena1DataGridViewColumn":
						KlijentList[e.RowIndex].Napomena1 = (System.String)e.Value;
						break;
					case "uxNapomena2DataGridViewColumn":
						KlijentList[e.RowIndex].Napomena2 = (System.String)e.Value;
						break;
					case "uxIDTipDataGridViewColumn":
						KlijentList[e.RowIndex].IDTip = (System.Int32)e.Value;
						break;
					case "uxOIBDataGridViewColumn":
						KlijentList[e.RowIndex].OIB = (System.String)e.Value;
						break;
					case "uxGarancijaPlacanjaOpisDataGridViewColumn":
						KlijentList[e.RowIndex].GarancijaPlacanjaOpis = (System.String)e.Value;
						break;
					case "uxGarancijaPlacanjaVrijednostDataGridViewColumn":
						KlijentList[e.RowIndex].GarancijaPlacanjaVrijednost = (System.Decimal?)e.Value;
						break;
					case "uxDaniOdgodePlacanjaDataGridViewColumn":
						KlijentList[e.RowIndex].DaniOdgodePlacanja = (System.Int32?)e.Value;
						break;
					case "uxKomentarDataGridViewColumn":
						KlijentList[e.RowIndex].Komentar = (System.String)e.Value;
						break;
				default:
				break;
			}
		}
	}
}
